package org.mango.validator;

import org.mango.validator.util.MyValidator;
import org.mango.validator.util.ValidContext;

import java.util.Map;

/**
 * Created by meigang on 17/9/15.
 */
public class B3Validator extends MyValidator {
    /**
     *
     * @param param 条件参数
     * @param validparam 验证参数
     * @param vc 验证上下文
     * @param msg 错误信息
     * @return
     */
    public boolean validate(Map<String, Object> param, Map<String,Object> validparam, ValidContext vc, String msg) {
        String b1 = param.get("b1").toString();
        if(b1.equals("mango")){
            String b3 = this.getString(validparam,"b3");
            if(b3!=null && b3.length()>0){
                return true;
            }else{
                vc.addError(validparam.keySet().toString(),msg);
            }
        }else{
            return true;
        }
        return false;
    }
}
